﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace TestWriteFile
{
    class Program
    {
        static void Main(string[] args)
        {
            string filename = "D:\\Huu Tai\\temp.txt";
            if (!File.Exists(filename))
            {
                using (System.IO.FileStream fs = System.IO.File.Create(filename))
                {
                    StreamWriter sw = new StreamWriter(fs);

                    sw.WriteLine("1,2");
                    sw.WriteLine("1,3");
                    sw.WriteLine("1,4");
                    sw.WriteLine("1,5");

                    sw.Flush();
                    fs.Close();
                }
            }
            else
            {
                using (System.IO.FileStream fs = File.OpenWrite(filename))
                {
                    StreamWriter sw = new StreamWriter(fs);

                    sw.Write(String.Empty);
                    sw.WriteLine("1,2");
                    sw.WriteLine("1,3");
                    sw.WriteLine("1,4");
                    sw.WriteLine("1,0");

                    sw.Flush();
                    fs.Close();
                }
            }
        }
    }
}
